<extend name="Public/base"/>
<block name="body">
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title">
        <h2>area</h2>
    </div>
    <form action="{:U('addpicthumb')}" method="post" class="form-horizontal">
        <div class="form-item">
            <label class="item-label">分类展示图片</label>
            <div class="controls">
				<input type="file" id="upload_picture_pic">
				<input type="hidden" name="pic" id="cover_id_pic"/>
				<input type="hidden" name="pic_path" id="cover_id_path"/>
				<input type="hidden" name="pic_savename" id="cover_savename"/>
				<div class="upload-img-box"></div>
			</div>
			<script type="text/javascript">
			//上传图片
			/* 初始化上传插件 */
			$("#upload_picture_pic").uploadify({
				"height"          : 30,
				"swf"             : "__STATIC__/uploadify/uploadify.swf",
				"fileObjName"     : "download",
				"buttonText"      : "上传图片",
				"uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
				"width"           : 120,
				'removeTimeout'	  : 1,
				'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
				"onUploadSuccess" : uploadPicturepic
			});
			function uploadPicturepic(file, data){
				var data = $.parseJSON(data);
				var src = '';
				if(data.status){
					$("#cover_id_pic").val(data.id); 
					$("#cover_savename").val(data.savename);
					src = data.url || '__ROOT__' + data.path
					//$("#cover_id_path").val('__ROOT__' + src + '');
					$("#cover_id_path").val('__ROOT__' + src.replace(data.savename,'') + '');
					$("#cover_id_pic").parent().find('.upload-img-box').html(
						'<div class="upload-pre-item"><img src="__ROOT__' + src + '"/></div>'
					);
				} else {
					updateAlert(data.info);
					setTimeout(function(){
						$('#top-alert').find('button').click();
						$(that).removeClass('disabled').prop('disabled',false);
					},1500);
				}
			}
			</script>
        </div>
		
        <div class="form-item">
            <button class="btn submit-btn" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>